wayland: Build with G_DISABLE_ASSERT
authorEmmanuele Bassi <ebassi@gnome.org>
Mon, 12 Apr 2021 10:59:56 +0000 (11:59 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 13 Apr 2021 01:26:02 +0000 (21:26 -0400)
gdk/wayland/gdkdevice-wayland.c
gdk/wayland/gdkdisplay-wayland.c

index 5211cbbbda79cf420a66fc7bdee6b5c76a2040c2..f065d2cc30c88d5b7f4903663f9831eddc197bcc 100644 (file)
@@ -848,7 +848,12 @@ gdk_wayland_device_pad_get_n_groups (GdkDevicePad *pad)
 
   data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
                                     GDK_DEVICE (pad));
+#ifdef G_DISABLE_ASSERT
+  if (data == NULL)
+    return 0;
+#else
   g_assert (data != NULL);
+#endif
 
   return g_list_length (data->mode_groups);
 }
@@ -863,7 +868,12 @@ gdk_wayland_device_pad_get_group_n_modes (GdkDevicePad *pad,
 
   data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
                                     GDK_DEVICE (pad));
+#ifdef G_DISABLE_ASSERT
+  if (data == NULL)
+    return 0;
+#else
   g_assert (data != NULL);
+#endif
 
   group = g_list_nth_data (data->mode_groups, n_group);
   if (!group)
@@ -909,7 +919,12 @@ gdk_wayland_device_pad_get_feature_group (GdkDevicePad        *pad,
 
   data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
                                     GDK_DEVICE (pad));
+#ifdef G_DISABLE_ASSERT
+  if (data == NULL)
+    return -1;
+#else
   g_assert (data != NULL);
+#endif
 
   for (l = data->mode_groups, i = 0; l; l = l->next, i++)
     {
@@ -4236,7 +4251,14 @@ tablet_pad_handle_button (void                     *data,
                        wp_tablet_pad, button, state));
 
   group = tablet_pad_lookup_button_group (pad, button);
+
+#ifdef G_DISABLE_ASSERT
+  if (group == NULL)
+    return;
+#else
   g_assert (group != NULL);
+#endif
+
   n_group = g_list_index (pad->mode_groups, group);
 
   event = gdk_pad_event_new_button (state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED
index ba36d0bb826a053dc9970c17e9a781caae502fc6..5a6599968262e249517cdaadd8c972869f12fd9b 100644 (file)
 
 #include "gdk/gdk-private.h"
 
+/* Keep g_assert() defined even if we disable it globally,
+ * as we use it in many places as a handy mechanism to check
+ * for non-NULL
+ */
+#ifdef G_DISABLE_ASSERT
+# undef g_assert
+# define g_assert(expr)                  G_STMT_START { \
+                                           if G_LIKELY (expr) ; else \
+                                             g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
+                                                                       #expr); \
+                                         } G_STMT_END
+#endif
+
 /**
  * GdkWaylandDisplay:
  *